home *** CD-ROM | disk | FTP | other *** search
- Path: Inter.NL.net!usenet
- From: Auke.Reitsma@net.HCC.nl (Auke Reitsma)
- Newsgroups: comp.lang.c
- Subject: Re: Help needed - fgets and EOF
- Date: Fri, 15 Mar 1996 18:56:32 GMT
- Organization: Inter.NL.net, The Internet Provider in The Netherlands.
- Message-ID: <4icer9$df5@altrade.nijmegen.inter.nl.net>
- References: <Do2y8w.K8v@murdoch.acc.Virginia.EDU>
- Reply-To: Auke.Reitsma@net.HCC.nl
- NNTP-Posting-Host: rt99-4.rotterdam.nl.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- brr7q@virginia.edu wrote:
-
- > Hi
-
- > I wrote what I thought would be a simple application (DOS). It reads lines
- > from a file character by character using fgets. I check each character
- > for and newline (\n) and EOF. The program works as long as the file
- > has lf at the end of the last record, BUT, if the last record does not
- > end with a <lf> then the program bombs. When debugging my code I
- > find that the last character read in is hex ff (255 ascii). I trap this to signal
- > the end of the process, but the program still bombs. It doesn't bomb
- > untill it closes all the files and is just ready to exit the program.
-
- > What I need to know is what is causing this bomb. The situation arises when a
- > data file has been edited but the last line does not end with a lf.
-
- Without code I can't really say anything about it, but the most common
- mistake by beginners is assuming that EOF is reached when they have read
- all data.
- EOF is ONLY detected AFTER you try to read PAST the end of the file ...
-
-
- Greetings from Delft, The Netherlands.
-
- Auke Reitsma
-
-